<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath() + "/";
%>
<!DOCTYPE html>
<html>
<head>
<base href="<%=path%>" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>详细描述</title>
	<script type="text/javascript" src="js/jquery-3.3.1.min.js"></script>
    <link rel="stylesheet" href="css/bootstrap.min.css" type="text/css"/>
    <link href="css/reg.css" rel="stylesheet" type="text/css">
    <link rel="stylesheet" href="css/base.css" type="text/css"/>
    <link rel="stylesheet" href="css/headbott.css" type="text/css"/>
    <link rel="stylesheet" href="css/index.css" type="text/css"/>
    <link rel="stylesheet" href="css/ly-list.css" type="text/css"/>
    <link rel="stylesheet" href="css/reg.css" type="text/css"/>
    <link rel="stylesheet" href="css/detail.css" type="text/css"/>
</head>
<body>
<div id="header">
    <%@include file="/WEB-INF/view/navigation.jsp"%>
</div>
<!--中间-->
<div class="product">
    <!--头上表格-->
    <%@include file="/WEB-INF/view/product/select.jsp" %>
    <!--下部foem表单-->
    <div class="product-form">
        <!--上标题-->
        <div class="product-title">
            <div class="my-h4">
                <h4>描述你的项目详情</h4>
            </div>
            <div class="btn-save">
                <button onclick="save()" class="btn btn-default">保存草稿</button>
            </div>

        </div>
        <div class="clear"></div>
        <hr>
        <!--表单-->
        <!--宣传视频-->
        <!-- <div>
            <form>
            </form>
        </div> -->
        <div class="clear"></div>
        <hr>
        <!--编辑信息表单-->
        <form action="product/adddetail" method="post" id="form" >
            <div class="my-form">
                <div class="detail"><b>宣传视频：</b><input id="videoUrl" name="videoUrl" value="${productDetail.videoUrl }" class="detail-input" placeholder="填写视频在线播放地址"></div>
                <div class="detail"><b>项目故事：</b><div><textarea id="story" name="story"  rows="2" placeholder="一句话介绍一下你的项目吧">${productDetail.story }</textarea></div></div>
                <div class="detail"><b>更多支持：</b><div><textarea id="suppot" name="suppot"  rows="2" placeholder="一句话介绍一下你的项目吧">${productDetail.suppot }</textarea></div></div>
                <div class="detail"><b>提供回报：</b><div><textarea id="report" name="report"  rows="2" placeholder="一句话介绍一下你的项目吧">${productDetail.report }</textarea></div></div>
                <div class="detail"><b>关于我：</b><div><textarea id="me" name="me" rows="2" placeholder="一句话介绍一下你的项目吧">${productDetail.me }</textarea></div></div>
            </div>
        </form>
        ${msg }
    </div>
</div>
<!--下部-->
<div id="bottom">
    <jsp:include page="/WEB-INF/view/tail.jsp"></jsp:include>
</div>
	<script type="text/javascript">
		
		function save(){
			var videoUrl=$("#videoUrl").val();
			var story=$("#story").val();
			var suppot=$("#suppot").val();
			var report=$("#report").val();
			var me=$("#me").val();
			if(videoUrl=="" || videoUrl==null){
				alert("宣传视频不能为空");
			}else if(story=="" || story==null){
				alert("项目故事不能为空");
			}else if(suppot=="" || suppot==null){
				alert("更多支持不能为空");
			}else if(report=="" || report==null){
				alert("提供回报为空");
			}else if(me=="" || me==null){
				alert("关于我不能为空");
			}else{
					var formData = new FormData($("#form")[0]); //用form 表单直接 构造formData 对象; 就不需要下面的append 方法来为表单进行赋值了。 
					$.ajax({
						url : 'product/adddetail',
						type : 'POST',
						async : true,
						data : formData,
						dataType : 'json',
						contentType : false, //必须false才会自动加上正确的Content-Type 
						processData : false, //必须false才会避开jQuery对 formdata 的默认处理   				
						success : function(data) {
							if (data.code == 200) {
								alert("保存错草稿成功");
								window.location.href="/Crowdfunding/product/to/repay";
							} else {
								alert("保存草稿失败,原因:可能未登录");
							}
						}

					});				
			}
		}
	</script>

</body>
</html>